﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RPGMapa.Data;

namespace RPGMapa.Controls
{
    public partial class TilePicker : TilePanel
    {
        private ImgMatrix tileset;

        public ImgMatrix Tileset
        {
            get { return tileset; }
            set { tileset = value; }
        }
        public Vector2 TileSize
        {
            get { return new Vector2(tileset.OffX, tileset.OffY); }
        }
        public Vector2 TileNumber
        {
            get { return new Vector2(tileset.NumberX, tileset.NumberY); }
        }

        public TilePicker()
        {
            InitializeComponent();
            this.tileset = ImgMatrix.DefautTileset();
        }
        public TilePicker(ImgMatrix tileSet)
        {
            InitializeComponent();
            this.tileset = tileSet;
        }


        public void DrawSelectedSquare(Point e)
        {
            gAlphaLayer.Clear(Color.Transparent);
            gAlphaLayer.DrawImageUnscaled(BackBuffer, Point.Empty);
            gAlphaLayer.DrawRectangle(
                new Pen(Color.White, 3f),
                new Rectangle(
                    e.X - e.X % tileset.OffX,
                    e.Y - e.Y % tileset.OffY,
                    tileset.OffX,
                    tileset.OffY));

            gControl.DrawImageUnscaled(AlphaLayer, Point.Empty);
        }
    }
}
